package ru.spb.osll.myfit.server.parser;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

import ru.spb.osll.myfit.common.Table;
import ru.spb.osll.myfit.common.TableStyle;
import ru.spb.osll.myfit.fixtures.base.DummyOneLineFixture;
import ru.spb.osll.myfit.util.CollectionUtils;
import fitlibrary.DoFixture;
import fitlibrary.SetUpFixture;

public class TableUtilsTest {
	private TableElementParser m_parser = new TableElementParser();

	@Test
	public void testTableToString() {
		Table table = m_parser.parseTable(CollectionUtils.list(
    "|enable advanced retention on clusters|"));
		assertEquals("|enable advanced retention on clusters|"
				+ Constants.LINE_SEPARATOR, PageParserUtils
				.tableToString(table));
		table = m_parser.parseTable(CollectionUtils.list(
        "|with cubetools|", "|write|10|files of size|10KB|using|10|threads"));
		assertEquals("|with cubetools|" + Constants.LINE_SEPARATOR
				+ "|write|10|files of size|10KB|using|10|threads|"
				+ Constants.LINE_SEPARATOR, PageParserUtils
				.tableToString(table));
	}

	private static class DummyDoFixture extends DoFixture {
	}

	private static class DummySetUpFixture extends SetUpFixture {
	}

	@Test
	public void testGetTableStyle() {
		assertEquals(TableStyle.ONE_LINE_FIXTIRE, PageParserUtils
				.getTableStyle(DummyOneLineFixture.class));
		assertEquals(TableStyle.DO_FIXTURE, PageParserUtils
				.getTableStyle(DummyDoFixture.class));
		assertEquals(TableStyle.SETUP_FIXTURE, PageParserUtils
				.getTableStyle(DummySetUpFixture.class));
	}

}
